#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

const int BASE = 10;

template<typename T>
ostream& operator<<(ostream& out, vector<T> const & v) {
    out << "[ ";
    for (size_t = 0; i < v.size(); ++i) {
        if (i != 0) {
            out << ", ";
        }
        out << v[i];
    }
    out << " ]";
    return out;
}

bool is_zero(vector<int> const & a) {
    return (a.size() == 1) && (a[0] == 0);
}

bool less_(vector<int> const & a, vector<int> const & b) {
    if (a.size() != b.size()) {
        return a.size() < b.size();
    }

    int len = a.size();

    for (int i = len - 1; i >= 0; --i) {
        if (a[i] != b[i]) {
            return a[i] < b[i];
        }
    }
    return false;
}

void trim(vector<int>& res) {
    while ((res.back() == 0) && (res.size() > 1)) {
        res.pop_back();
    }
}

vector<int> mult_on_digit(vector<int> const & a, int d) {
    int carry = 0;
    vector<int> res;
    res.reserve(a.size() + 1);
    for (size_t i = 0; i < a.size(); ++i) {
        int v = carry + a[i] * d;
        carry = v / BASE;
        res.push_back(v % BASE);
    }

    if (carry > 0) {
        res.push_back(carry);
    }

    trim(res);
    // cerr << a << " * " << d << " = " << res << "\n";
    return res;
}

vector<int> subtract(vector<int> const & a, vector<int> const & b) {
    assert(!less_(a, b));
    vector<int> res(a.size());

    int uncarry = 0;
    for (size_t i = 0; i < a.size(); ++i) {
        int subtrahend = (i < b.size()) ? b[i] : 0;
        int t = a[i] - uncarry - subtrahend;
        if (t >= 0) {
            uncarry = 0;
        } else {
            uncarry = 1;
            t += BASE;
        }
        res[i] = t;
    }

    trim(res);
    // cerr << a << " - " << b << " = " << res << "\n";
    return res;
}

vector<int> power_of_base(vector<int> const & a, int p) {
    assert(!is_zero(a));
    assert(p >= 0);

    vector<int> res(a.size() + p);
    copy(a.begin(), a.end(), res.begin() + p);
    // cerr << a << " << " << p << " = " << res << "\n";
    return res;
}

pair<vector<int>, vector<int> > div_mod(
        vector<int> a,
        vector<int> const & b) {
    assert(!is_zero(b));
    // cerr << a << " / " << b << "...\n";

    int size_diff = a.size() - b.size();
    vector<int> quotient(max(size_diff, 0) + 1);

    for (int i = size_diff; i >= 0; --i) {
        // cerr << "i = " << i << "\n";
        vector<int> tb = power_of_base(b, i);
        if (less_(a, tb)) {
            continue;
        }
        // cerr << a << " /? " << tb << "\n";
        int min_digit = a.back() / (tb.back() + 1);
        int max_digit = (a.back() + 1) / tb.back();
        // int min_digit = 0;
        // int max_digit = 10;
        for (int d = min_digit + 1; d <= max_digit; ++d) {
            // cerr << "d = " << d << "\n";
            vector<int> c = mult_on_digit(tb, d);
            if (less_(a, c)) {
                a = subtract(a, mult_on_digit(tb, d - 1));
                quotient[i] = d - 1;
                break;
            }
        }
    }

    trim(quotient);
    return make_pair(quotient, a);
}

int main() {
    ifstream fin("in.txt");
    ofstream fout("out.txt");

    string a, b;
    while (fin >> a >> b) {
        if (b == "0") {
            fout << "<error>\n\n\n";
            continue;
        }
        vector<int> av(a.length());
        vector<int> bv(b.length());
        for (size_t i = 0; i < a.length(); ++i) {
            av[a.length() - i - 1] = a[i] - '0';
        }

        for (size_t i = 0; i < b.length(); ++i) {
            bv[b.length() - i - 1] = b[i] - '0';
        }

        assert(is_zero(subtract(av, mult_on_digit(av, 1))));
        assert(is_zero(subtract(bv, mult_on_digit(bv, 1))));
        pair<vector<int>, vector<int> > p = div_mod(av, bv);

        for (int i = p.first.size() - 1; i >= 0; --i) {
            fout << p.first[i];
        }
        fout << "\n";

        for (int i = p.second.size() - 1; i >= 0; --i) {
            fout << p.second[i];
        }
        fout << "\n\n";


    }
    return 0;
}
